Imports Iesi.Collections.Generic

Namespace Entities

    Public Class PerformanceEvaluation
        Implements IDomainEntity

        Protected Sub New()

        End Sub

        Public Sub New(ByVal id As Guid, ByVal evaluated As User, ByVal evaluator As User, ByVal startDate As DateTime, ByVal endDate As DateTime)

            Dim cachedDateTime As DateTime = DateTime.Now

            Me.Id = id
            Me.Evaluated = evaluated
            Me.Evaluator = evaluator
            Me.StartDate = startDate
            Me.EndDate = endDate
            Me.CreatedDate = cachedDateTime
            Me.LastModified = cachedDateTime

        End Sub

        Public Sub New(ByVal evaluated As User, ByVal evaluator As User, ByVal startDate As DateTime, ByVal endDate As DateTime)
            Me.New(Guid.NewGuid(), evaluated, evaluator, startDate, endDate)
        End Sub

        Private _id As Guid
        Public Overridable Property Id() As System.Guid Implements IDomainEntity.Id
            Get
                Return _id
            End Get
            Set(ByVal value As System.Guid)
                _id = value
            End Set
        End Property

        Private _evaluated As User
        Public Overridable Property Evaluated() As User
            Get
                Return _evaluated
            End Get
            Set(ByVal value As User)
                _evaluated = value
            End Set
        End Property

        Private _evaluator As User
        Public Overridable Property Evaluator() As User
            Get
                Return _evaluator
            End Get
            Set(ByVal value As User)
                _evaluator = value
            End Set
        End Property

        Private _startDate As DateTime
        Public Overridable Property StartDate() As DateTime
            Get
                Return _startDate
            End Get
            Set(ByVal value As DateTime)
                _startDate = value
            End Set
        End Property

        Private _endDate As DateTime
        Public Overridable Property EndDate() As DateTime
            Get
                Return _endDate
            End Get
            Set(ByVal value As DateTime)
                _endDate = value
            End Set
        End Property

        Private _goalRatings As ISet(Of GoalRating) = New HashedSet(Of GoalRating)
        Public Overridable Property GoalRatings() As ISet(Of GoalRating)
            Get
                Return _goalRatings
            End Get
            Set(ByVal value As ISet(Of GoalRating))
                _goalRatings = value
            End Set
        End Property

        Private _comments As String
        Public Overridable Property Comments() As String
            Get
                Return _comments
            End Get
            Set(ByVal value As String)
                _comments = value
            End Set
        End Property

        Private _createdDate As DateTime

        Public Overridable Property CreatedDate() As Date Implements IDomainEntity.CreatedDate
            Get
                Return _createdDate
            End Get
            Set(ByVal value As Date)
                _createdDate = value
            End Set
        End Property

        Private _lastModified As DateTime
        Public Overridable Property LastModified() As Date Implements IDomainEntity.LastModified
            Get
                Return _lastModified
            End Get
            Set(ByVal value As Date)
                _lastModified = value
            End Set
        End Property

        Private _isDeleted As Boolean
        Public Overridable Property IsDeleted() As Boolean Implements IDomainEntity.IsDeleted
            Get
                Return _isDeleted
            End Get
            Set(ByVal value As Boolean)
                _isDeleted = value
            End Set
        End Property

        Public Overridable Function GetGoalRating(ByVal goalId As Guid) As GoalRating

            Dim result As GoalRating = Nothing

            For Each gr As GoalRating In Me.GoalRatings
                If gr.Goal.Id = goalId Then
                    result = gr
                End If
            Next

            Return result

        End Function

        Public Overridable Sub Validate() Implements IValidableEntity.Validate

        End Sub

        Public Overridable Sub ValidateDelete() Implements IValidableEntity.ValidateDelete

        End Sub
    End Class

End Namespace
